home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / RIncludes / CodeFragments.r < prev    next >
Encoding:
Text File  |  1997-08-12  |  9.7 KB  |  263 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        CodeFragments.r
  3.  
  4.      Contains:    Public Code Fragment Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1992-1997 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18.  
  19. #ifndef __CODEFRAGMENTS_R__
  20. #define __CODEFRAGMENTS_R__
  21.  
  22. #ifndef __CONDITIONALMACROS_R__
  23. #include "ConditionalMacros.r"
  24. #endif
  25.  
  26.  
  27. /*
  28.     The 'cfrg' resource serves to inform the Process Manager and Code Fragment Manager
  29.     of code fragments present in this file.
  30.     
  31.     The 'cfrg' resource must have an ID of 0.  There can only be one 'cfrg' resource
  32.     per file, however, the trailing part of a 'cfrg' resource is an array of entries.
  33.     Each entry can be used to associate a name and architecture type to a specified 
  34.     code fragment. The names are used when the system searches for code fragments as 
  35.     named shared libraries.  There can be more than one cfrg array entry per code 
  36.     fragment, this is used to give a single code fragment more than one name.
  37.  
  38.     For Applications
  39.        The 'cfrg' is required to inform the Process Manager that there is a 
  40.        code fragment available.  One of the entries which has the architecture
  41.        type appropriate for the given machine (ie: pwpc, or m68k) should have the 
  42.        kIsApp usage designation.  The Process Manager will choose this code fragment 
  43.        over the traditional CODE 0.  The location of the code fragment (usually in 
  44.        the data fork) is described within the cfrg array entry.  
  45.        
  46.        For applications, the name is important only when an application has by name 
  47.        call backs, that is, exports for drop in extensions that import from the 
  48.        application.  Generally speaking, the name of the application is used for 
  49.        its 'cfrg' array entry.
  50.        
  51.     For Shared Libraries
  52.        The 'cfrg' is required to allow the Code Fragment Manager to find shared 
  53.        libraries. 
  54.        
  55.        Shared Libraries are libraries that satisfy link time imports, that are 
  56.        usually placed in the extensions folder; they are automatically connected to 
  57.        by the Code Fragment Manager at application launch time.  Shared Libraries
  58.        must have the file type 'shlb'.  The usage field is set to kIsLib for shared 
  59.        libraries.
  60.  
  61.  
  62.     Plug-in extensions (code fragments packaged in various application specific ways)
  63.     are that loaded programaticallly by the application do not require the file type 
  64.     'shlb' and a cfrg resource, but may use some similar mechanism that is application
  65.     specific and developer defined.
  66.  
  67.  
  68.     There are two versions of the 'cfrg' resource template.
  69.  
  70.     The original version (cfrg_RezTemplateVersion = 0) is appropriate for 
  71.     applications and most shared libraries.
  72.     
  73.     The second version (cfrg_RezTemplateVersion = 1) is needed only when the code 
  74.     fragment will be found using the new CFM/SOM search mechanisms. It
  75.     contains additional information.
  76.     
  77.     In order to mix both kinds of entries in one 'cfrg' resources, the second
  78.     version of the template contains a switch statement for specifying which
  79.     kind of entry is being generated.  The following example shows how to 
  80.     convert a cfrg_RezTemplateVersion=0 format to a cfrg_RezTemplateVersion=1
  81.     format 'cfrg' resource:            
  82.  
  83.  
  84.     When cfrg_RezTemplateVersion=0 use:
  85.     
  86.                 resource 'cfrg' (0) {
  87.                     {
  88.                         kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  89.                         kDefaultStackSize, kNoAppSubFolder,
  90.                         kApplicationCFrag, kDataForkCFragLocator, kZeroOffset, kCFragGoesToEOF,
  91.                         "My Application",
  92.                     }
  93.                 };
  94.                 
  95.     when cfrg_RezTemplateVersion=1 use:
  96.                 resource 'cfrg' (0) {
  97.                     {
  98.                         regularEntry {        // <--- add this line     
  99.                             kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  100.                             kDefaultStackSize, kNoAppSubFolder,
  101.                             kApplicationCFrag, kDataForkCFragLocator, kZeroOffset, kCFragGoesToEOF,
  102.                             "My Application",
  103.                         }                    // <--- and this line 
  104.                     }
  105.                 };
  106.                 
  107.     The compiled binary resource is identical.
  108.     
  109.     The extended form allows specification of an OSType and 4 Str255s that are 
  110.     used as criterea in searching for libraries that satisfy some contstraints.
  111.     For example, a SOM class library that is a particular sub-class of the 
  112.     "ClassXYZ" base class, might be represented as :
  113.                 resource 'cfrg' (0) {
  114.                     {
  115.                         extendedEntry {
  116.                             kPowerPCCFragArch, kIsCompleteCFrag, kNoVersionNum, kNoVersionNum,
  117.                             kDefaultStackSize, kNoAppSubFolder,
  118.                             kImportLibraryCFrag,kOnDiskFlat,kZeroOffset,kCFragGoesToEOF,
  119.                             "MyLibName",    // standard internal name: used by CFM 
  120.                             // start of extended info 
  121.                             kFragSOMClassLibrary,
  122.                             "ClassXYZ",
  123.                             "",
  124.                             "",
  125.                             "My Name"        // external name: may be seen by user 
  126.                         }
  127.                     }
  128.                 };
  129.     Using the new CFM/SOM search functions, one could search for all som
  130.     class libraries that inherit from "ClassXYZ".
  131. */
  132.  
  133.  
  134. /*---------------------------cfrg • CodeFragments---------------------------*/
  135. /*
  136.     cfrg_RezTemplateVersion:
  137.         0 - original                         <-- default
  138.         1 - extended for SOM 
  139. */
  140. #ifndef cfrg_RezTemplateVersion
  141.     #ifdef UseExtendedCFRGTemplate                            /* grandfather in use of “UseExtendedCFRGTemplate” */
  142.         #define cfrg_RezTemplateVersion 1
  143.     #else
  144.         #define cfrg_RezTemplateVersion 0
  145.     #endif
  146. #endif
  147.  
  148.  
  149. /* grandfather in old names for fields */
  150. #define kIsLib                 kImportLibraryCFrag
  151. #define kIsApp                 kApplicationCFrag
  152. #define kIsDropIn             kDropInAdditionCFrag
  153. #define kInMem                 kMemoryCFragLocator
  154. #define kOnDiskFlat         kDataForkCFragLocator
  155. #define kOnDiskSegmented     kResourceCFragLocator
  156. #define kPowerPC             kPowerPCCFragArch
  157. #define kMotorola             kMotorola68KCFragArch
  158. #define kFullLib             kIsCompleteCFrag
  159. #define kUpdateLib             kFirstCFragUpdate
  160. #define kWholeFork             kCFragGoesToEOF
  161.  
  162.  
  163. type 'cfrg' {
  164.    longint = 0;            /* reserved - in use */
  165.    longint = 0;            /* reserved - in use */
  166.    longint = 1;            /* cfrgVersion       */
  167.    longint = 0;            /* reserved - in use */
  168.    longint = 0;            /* reserved - in use */
  169.    longint = 0;            /* reserved - free   */
  170.    longint = 0;            /* reserved - free   */
  171.    longint = $$CountOf (memberArray);
  172.    Array memberArray {
  173.      memberStart:
  174.       align long;
  175.       
  176. #if cfrg_RezTemplateVersion == 1
  177.       switch{
  178.       case regularEntry:
  179. #endif    
  180.         literal longint archType, kPowerPCCFragArch = 'pwpc', kMotorola68KCFragArch = 'm68k';
  181.         longint         updateLevel, kIsCompleteCFrag = 0, kFirstCFragUpdate = 1;
  182.         longint         currentVersion, kNoVersionNum = 0;
  183.         longint         oldDefVersion, kNoVersionNum = 0;
  184.         longint         appStackSize, kDefaultStackSize = 0;
  185.         integer         appSubFolderID, kNoAppSubFolder = 0;
  186.         byte            usage, kImportLibraryCFrag = 0, kApplicationCFrag = 1, 
  187.                             kDropInAdditionCFrag = 2, kStubLibraryCFrag = 3, 
  188.                             kWeakStubLibraryCFrag = 4;
  189.         byte            where, kMemoryCFragLocator = 0, kDataForkCFragLocator = 1, 
  190.                             kResourceCFragLocator = 2;
  191.         longint         offset, kZeroOffset = 0, kRSEG = 'rseg';
  192.         longint         length, kCFragGoesToEOF = 0, kSegIDZero = 0;
  193.         longint         = 0;      /* reserved - free */
  194. #if cfrg_RezTemplateVersion == 1
  195.         integer         = 0;      /* reserved - free */
  196.         key integer     = 0;      /* no cfrg extensions */
  197. #else
  198.         longint         = 0;      /* reserved - free   */
  199. #endif
  200.         integer         = (memberEnd[$$ArrayIndex(memberArray)] - memberStart[$$ArrayIndex(memberArray)]) / 8;
  201.         pstring;        /* member name */
  202.  
  203.  
  204. #if cfrg_RezTemplateVersion == 1
  205.       case extendedEntry:
  206.         literal longint archType, kPowerPCCFragArch = 'pwpc', kMotorola68KCFragArch = 'm68k';
  207.         longint         updateLevel, kIsCompleteCFrag = 0, kFirstCFragUpdate = 1;
  208.         longint         currentVersion, kNoVersionNum = 0;
  209.         longint         oldDefVersion, kNoVersionNum = 0;
  210.         longint         appStackSize, kDefaultStackSize = 0;
  211.         integer         appSubFolderID, kNoAppSubFolder = 0;
  212.         byte            usage, kImportLibraryCFrag = 0, kApplicationCFrag = 1, 
  213.                             kDropInAdditionCFrag = 2, kStubLibraryCFrag = 3, 
  214.                             kWeakStubLibraryCFrag = 4;
  215.         byte            where, kMemoryCFragLocator = 0, kDataForkCFragLocator = 1, 
  216.                                 kResourceCFragLocator = 2;
  217.         longint         offset, kZeroOffset = 0, kRSEG = 'rseg';
  218.         longint         length, kCFragGoesToEOF = 0, kSegIDZero = 0;
  219.         longint         = 0;      /* reserved - free */
  220.         integer         = 0;      /* reserved - free */
  221.         key integer     = 1;      /* one extension   */
  222.         integer         = (memberEnd[$$ArrayIndex(memberArray)] - memberStart[$$ArrayIndex(memberArray)]) / 8;
  223.         pstring;        /* member name */
  224.         align long;     /* match size to C structure size */
  225.         extensionStart: 
  226.         integer          = 0x30ee;       /* magic # signifies this extended cfrg entry format */
  227.         integer         = (extensionEnd[$$ArrayIndex(memberArray)] - extensionStart[$$ArrayIndex(memberArray)]) / 8;
  228.         literal longint libKind, 
  229.                     kFragDocumentPartHandler     = 'part',
  230.                     kFragSOMClassLibrary         = 'clas',
  231.                     kFragInterfaceDefinition     = 'libr',
  232.                     kFragComponentMgrComponent    = 'comp';
  233.                     /* others allowed, need to be a DTS registered OSType */
  234.         pstring;          /* qualifier 1: 
  235.                             'part' : part handler type
  236.                             'clas' : base class name
  237.                             'libr' : interface definition name
  238.                             'comp' : component kind
  239.                       */
  240.  
  241.  
  242.         pstring;          /* qualifier 2:
  243.                             'part' : part handler sub type ?
  244.                             'clas' : not used
  245.                             'libr' : not used
  246.                             'comp' : component sub kind
  247.                       */
  248.         pstring;          /* infoStr, optional information depending on libKind */
  249.         pstring;          /* intlName, an internationalizable string that can
  250.                          be displayed to the user on the screen */
  251.         align long;
  252.        extensionEnd:
  253.       };
  254. #endif
  255.      align long;
  256.      memberEnd:
  257.    };
  258. };
  259.  
  260.  
  261. #endif /* __CODEFRAGMENTS_R__ */
  262.  
  263.